package org.vergil.core.designpattern.state.Lift;

/**
 * Created by vergil on 17-3-25.
 */
public class Context {

    private static LiftState liftState = new ClosingState();
    //定义出所有的电梯状态
    public final static OpenningState openningState =
            new OpenningState(liftState);
    public final static ClosingState closingState =
            new ClosingState(liftState);
    public final static RunningState runningState =
            new RunningState(liftState);
    public final static StoppingState stoppingState =
            new StoppingState(liftState);

    public LiftState getLiftState() {
        System.out.println("状态:"+ liftState.getClass().getName());
        return liftState;
    }

    public void setLiftState(LiftState liftState) {
        this.liftState = liftState;
        // this.liftState.stop();
    }
    public void open() {
        this.liftState.open();
    }
    public void close() {
        this.liftState.close();
    }
    public void run() {
        this.liftState.run();
    }
    public void stop() {
        this.liftState.stop();
    }

}
